﻿using EfCore.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace EfCore.EntityConfig
{
    public class AnimalConfiguration : IEntityTypeConfiguration<Animal>
    {
        public void Configure(EntityTypeBuilder<Animal> builder)
        {
            builder.ToTable("T_Animal");
            builder.Property(p => p.Name).HasColumnName("MainName").HasColumnType("nvarchar").HasMaxLength(64).HasComment("主键").HasColumnOrder(1);
            builder.Property(p => p.Size).HasColumnName("AnimalSize").HasComment("大小").HasColumnOrder(2);
            builder.Property(p => p.LegCount).HasComment("腿数量").HasColumnOrder(3).HasDefaultValue(2).IsRequired(false);
            builder.HasKey(p=>p.Name);
            builder.Ignore(p => p.Color);


        }
    }
}
